#ifndef TABLE_H
#define TABLE_H

#include "key.h"
#include "cell.h"
#include <vector>
#include <optional>

namespace RealScan
{

// Abstract data structure for 2D discrete table.
template <typename T>
class Table
{
public:
    Table() = default;

    virtual ~Table() = default;

    /////// Basic operations //////////

    // Search for a cell. 
    virtual std::optional<T> search(const Key& key) const = 0;

    // Insert or change a cell.
    virtual bool insert(const Key& key, const T& value) = 0;

    // Remove a cell.
    virtual void remove(const Key& key) = 0;

    /////// Block retrieve //////////

    // Vectorize
    virtual void toVector(std::vector<Cell<T> >& vec, const Key& minXY, const Key& maxXY) const = 0;

    /////// Properties //////////
    
    // Get the number of units
    virtual std::size_t size() const = 0;

    // Get the space usage in memory
    virtual std::size_t space() const = 0;
};

} /* RealScan */

#endif /* TABLE_H */